package com.wzy.config;


import com.baomidou.mybatisplus.annotation.DbType;
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class MyConfig {
    @Bean
    public MybatisPlusInterceptor mybatisPlusInterceptor() {
        MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
        //mybatis-plus插件集合, 任何mybatis-plus插件加入到这个集合即可
        interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL));

        return interceptor;
        /***
         *     //设置分页参数  第几页 页容量
         *     Page<User> page = new Page<>(1, 5);
         *     userMapper.selectPage(page, null);
         *     //获取分页数据
         *     List<User> list = page.getRecords();
         *     list.forEach(System.out::println);
         *     System.out.println("当前页："+page.getCurrent());
         *     System.out.println("每页显示的条数："+page.getSize());
         *     System.out.println("总记录数："+page.getTotal());
         *     System.out.println("总页数："+page.getPages());
         *     System.out.println("是否有上一页："+page.hasPrevious());
         *     System.out.println("是否有下一页："+page.hasNext());
         */
    }
}
